#include <stdio.h>
#include <stdlib.h>

    char buf_1[255] = "#include <stdio.h>\n\
#include <stdlib.h>\n\
#include <string.h>\n\
#include <time.h>\n";
    char buf_3[255] = "int main(int argc, char const *argv[])\n\
{ \n \
    /* code */\n\
    return 0;\n\
}\
";

FILE *file_open(const char *path, const char *mode);

int file_close(FILE **fp);

int main(int argc, char const *argv[])
{
    FILE * fp = file_open( argv[1] , "w+");

    fprintf( fp ,"%s\n// 文件名:%s\n// 作者名:%s\n%s" , buf_1 , argv[1] , argv[2] ,  buf_3);

    file_close(&fp);
    return 0;
}



FILE *file_open(const char *path, const char *mode)
{
    FILE *fp = fopen(path, mode);
    if (NULL == fp)
    {
        printf("文件创建失败\n");
        exit(-1);    // 退出整个程序
    }
    return fp;
}

int file_close(FILE **fp)
{
    fclose(*fp);
    *fp = NULL;
}
